1 package tw.com.javaworld.CH16;
2 
3 import java.io.*;
4 import javax.servlet.jsp.*;
5 import javax.servlet.jsp.tagext.*;
6 
7 public class RepeatSimpleTag extends SimpleTagSupport {
8      
9     private int count = 0;
10    private JspFragment fragment;
11    
12    public void setCount(int count) {
13        this.count = count;
14    }
15    
16    public void setFragment(JspFragment fragment) {
17        this.fragment = fragment;
18    }
19    
20    public void doTag() throws JspException, IOException {
21    
22        JspContext ctx = getJspContext();
23        JspWriter out = ctx.getOut();
24            
25        for(int i=0 ; i<count ; i++) {
26            fragment.invoke(null);
27        }
28    }
29}